# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass machinelicm -o - %s | FileCheck -check-prefix=GCN %s

# MachineLICM shall limit hoisting of V_CVT instructions out of the loop keeping
# register pressure within the budget. VGPR budget at occupancy 10 is 24 vgprs.

---
name:            test
tracksRegLiveness: true
body:             |
  ; GCN-LABEL: name: test
  ; GCN: bb.0:
  ; GCN:   successors: %bb.1(0x80000000)
  ; GCN:   liveins: $vcc, $vgpr0
  ; GCN:   [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY4:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY5:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY6:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY7:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY8:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY9:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY10:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY11:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY12:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY13:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY14:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY15:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY16:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   [[COPY17:%[0-9]+]]:vgpr_32 = COPY $vgpr0
  ; GCN:   %18:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY]], implicit $mode, implicit $exec
  ; GCN:   %19:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY1]], implicit $mode, implicit $exec
  ; GCN:   %20:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY2]], implicit $mode, implicit $exec
  ; GCN:   %21:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY3]], implicit $mode, implicit $exec
  ; GCN:   %22:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY4]], implicit $mode, implicit $exec
  ; GCN: bb.1:
  ; GCN:   successors: %bb.2(0x04000000), %bb.1(0x7c000000)
  ; GCN:   liveins: $vcc
  ; GCN:   $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, %18, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, %19, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, %20, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, %21, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, %22, implicit $exec
  ; GCN:   %23:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY5]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %23, implicit $exec
  ; GCN:   %24:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY6]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %24, implicit $exec
  ; GCN:   %25:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY7]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %25, implicit $exec
  ; GCN:   %26:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY8]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %26, implicit $exec
  ; GCN:   %27:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY9]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %27, implicit $exec
  ; GCN:   %28:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY10]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %28, implicit $exec
  ; GCN:   %29:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY11]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %29, implicit $exec
  ; GCN:   %30:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY12]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %30, implicit $exec
  ; GCN:   %31:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY13]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %31, implicit $exec
  ; GCN:   %32:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY14]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %32, implicit $exec
  ; GCN:   %33:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY15]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %33, implicit $exec
  ; GCN:   %34:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY16]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %34, implicit $exec
  ; GCN:   %35:vreg_64 = nofpexcept V_CVT_F64_I32_e32 [[COPY17]], implicit $mode, implicit $exec
  ; GCN:   $vcc = V_CMP_EQ_U64_e64 $vcc, killed %35, implicit $exec
  ; GCN:   S_CBRANCH_VCCNZ %bb.1, implicit $vcc
  ; GCN:   S_BRANCH %bb.2
  ; GCN: bb.2:
  ; GCN:   S_ENDPGM 0
  bb.0:
    successors: %bb.1(0x80000000)
    liveins: $vcc, $vgpr0

    %0:vgpr_32 = COPY $vgpr0
    %1:vgpr_32 = COPY $vgpr0
    %2:vgpr_32 = COPY $vgpr0
    %3:vgpr_32 = COPY $vgpr0
    %4:vgpr_32 = COPY $vgpr0
    %5:vgpr_32 = COPY $vgpr0
    %6:vgpr_32 = COPY $vgpr0
    %7:vgpr_32 = COPY $vgpr0
    %8:vgpr_32 = COPY $vgpr0
    %9:vgpr_32 = COPY $vgpr0
    %10:vgpr_32 = COPY $vgpr0
    %11:vgpr_32 = COPY $vgpr0
    %12:vgpr_32 = COPY $vgpr0
    %13:vgpr_32 = COPY $vgpr0
    %14:vgpr_32 = COPY $vgpr0
    %15:vgpr_32 = COPY $vgpr0
    %16:vgpr_32 = COPY $vgpr0
    %17:vgpr_32 = COPY $vgpr0

  bb.1:
    successors: %bb.2(0x04000000), %bb.1(0x7c000000)
    liveins: $vcc

    $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
    %18:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %0, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %18, implicit $exec
    %19:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %1, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %19, implicit $exec
    %20:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %2, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %20, implicit $exec
    %21:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %3, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %21, implicit $exec
    %22:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %4, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %22, implicit $exec
    %23:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %5, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %23, implicit $exec
    %24:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %6, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %24, implicit $exec
    %25:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %7, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %25, implicit $exec
    %26:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %8, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %26, implicit $exec
    %27:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %9, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %27, implicit $exec
    %28:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %10, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %28, implicit $exec
    %29:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %11, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %29, implicit $exec
    %30:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %12, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %30, implicit $exec
    %31:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %13, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %31, implicit $exec
    %32:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %14, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %32, implicit $exec
    %33:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %15, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %33, implicit $exec
    %34:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %16, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %34, implicit $exec
    %35:vreg_64 = nofpexcept V_CVT_F64_I32_e32 %17, implicit $mode, implicit $exec
    $vcc = V_CMP_EQ_U64_e64 $vcc, killed %35, implicit $exec
    S_CBRANCH_VCCNZ %bb.1, implicit $vcc
    S_BRANCH %bb.2

  bb.2:
    S_ENDPGM 0

...
